﻿/*
 * Copyright 2008 Pimm Hogeling, Karim Sempel and Demian Sempel
 * 
 * This file is part of 8bitplays.
 * 
 * 8bitplays is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * 8bitplays is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with 8bitplays. If not, see <http://www.gnu.org/licenses/>.
 */
package nl.sandmen.team.gui {
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	/**
	 * @author Team Sandmen
	 */
	public class ControllButtons extends Sprite {
		[Embed(source="../../../../../media/Buttons.swf", symbol="ControllButtons")]
		private static const ASSET:Class;
		public var exit:MovieClip;
		public var minimize:MovieClip;
		public function ControllButtons():void {
			minimize = getAssetClip();
			exit = getAssetClip();
			addChild(minimize);
			addChild(exit);
			minimize.x = 16;
			minimize.y = 16;
			exit.x = 48;
			exit.y = 16
			minimize.gotoAndStop(1);
			exit.gotoAndStop(3);
		}
		private function getAssetClip():MovieClip {
			var movieClip:MovieClip = new ASSET();
			movieClip.buttonMode = true;
			movieClip.mouseChildren = false;
			movieClip.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
			return movieClip;
		}
		private function mouseOut(e:MouseEvent):void {
			e.currentTarget.removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
			e.currentTarget.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
			e.currentTarget.prevFrame();
		}
		private function mouseOver(e:MouseEvent):void {
			e.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);
			e.currentTarget.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
			e.currentTarget.nextFrame();
		}
	}
}